<?php

namespace Shopadmin\Controller;

use Think\Controller;

class AdminController extends Controller
{
    protected function _initialize()
    {
        $this->checkLogin();
    }

    private function checkLogin()
    {
        $shopid = session("shopid");
        if (empty($shopid)) {
            header("location:/Shopadmin/login/index");
            die();
        }

    }

    public function upload()
    {
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize = 3145728;// 设置附件上传大小
        $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->savePath = C('UPLOAD_PATH'); // 设置附件上传目录
        $upload->autoSub  = true;
        $upload->subName  = array('date','Y-m');
        $info = $upload->upload();
        if (!$info) {
           return $upload->getError();
        } else {
            return $info;
        }
    }

    public function create_image($url){
     vendor("phpqrcode.phpqrcode");
     $data =$url;
     $level = 'L';// 纠错级别：L、M、Q、H
     $size =4;// 点的大小：1到10,用于手机端4就可以了
     $QRcode = new \QRcode();
     ob_start();
     $name=get_rand_number();
     $path=C("QRIMG_PATH").$name.".png";

     $QRcode->png($data,$path,$level,$size,2);

    return $path;
 }

    /*
     *     public function jssdk_share(){
        vendor("Jssdk.jssdk");
        $appId = C("jssdk.appId");
        $appSecret = C("jssdk.appSecret");
        $jssdk = new \JSSDK($appId, $appSecret);
        $signPackage = $jssdk->GetSignPackage();

        $this->assign('signPackage',$signPackage);
    }
}
     * */
}

?>